package bubbleSort;

import emergent.Rule;

public class LookBottom implements Rule<BubbleSortWorld, Number> {

	@Override
	public void doAction(BubbleSortWorld world, Number agent) {
		int temp = agent.getBottomSideAgent().getNumberValue();
		agent.getBottomSideAgent().setNumberValue(agent.getNumberValue());
		agent.setNumberValue(temp);
		world.numberOfSwaps++;
	}

	@Override
	public boolean verifyGuard(BubbleSortWorld world, Number agent) {
		Number buttomSideAgent = agent.getBottomSideAgent();
		if (buttomSideAgent == null) return false;
		return (buttomSideAgent.getNumberValue()<agent.getNumberValue());
	}

}
